﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/Manager.master" AutoEventWireup="true" CodeFile="ManageEmailMarketing.aspx.cs" Inherits="EShop_ManageEmailMarketing" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script language="javascript" type="text/javascript">
    function CheckInput() {
        if (jQuery("#<%= ddlEmailTemplate.ClientID %>").val() == "-1") {
            jQuery("#<%= ddlEmailTemplate.ClientID %>").focus();
            alert("Xin chọn gói email. ");
            return false;
        }
        if (jQuery("#<%= txtSenderId.ClientID %>").val() == "") {
            alert("Người nhận email không được bỏ trống.");
            jQuery("#<%= txtSenderId.ClientID %>").focus();
            return false;
        }
        if (jQuery("#<%= txtEmailTitle.ClientID %>").val() == "") {
            alert("Tiêu đề email không được bỏ trống.");
            jQuery("#<%= txtEmailTitle.ClientID %>").focus();
            return false;
        }
        if (jQuery("#<%= txtEmailContent.ClientID %>").val() == "") {
            alert("Nội dung email không được bỏ trống.");
            jQuery("#<%= txtEmailContent.ClientID %>").focus();
            return false;
        }
        var arrSender = jQuery("#<%= txtSenderId.ClientID %>").val().split(";");
        var email_remaind = jQuery("#<%= hdMailRemaind.ClientID %>").val();
        if (arrSender.length > email_remaind) {
            alert("Số email còn lại trong gói đang chọn nhỏ hơn số email gởi đi.");
            return false;
        }
        return true;
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="content_area1">
        <h2>Quản Lý Email Marketing</h2>
        <div style="padding-left: 17px;">
        <asp:Label ID="lblEmailMarketingAlert" runat="server" ForeColor="Red" Visible="false"></asp:Label>
        <asp:GridView ID="grvManageEmailMarketing" runat="server" AutoGenerateColumns="false" 
                    AllowPaging="true" PageSize="20" Width="97%" CssClass="tableStyle">
                    <Columns>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Gói Điểm">
                            <ItemTemplate>
                              <%# Eval("Point")%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Center" HeaderText="Mẫu Email">
                            <ItemTemplate>
                                <%# Eval("EmailTemplateName")%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Sử Dụng Từ Ngày">
                            <ItemTemplate>
                                <%# Eval("StartDate", "{0:d}")%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Sử Dụng Đến Ngày">
                            <ItemTemplate>
                               <%# Eval("EndDate", "{0:d}")%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Tình Trạng">
                            <ItemTemplate>
                               <%# GetEmailPackageStatus(Eval("Status").ToString())%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Tổng mail đã đọc">
                            <ItemTemplate>
                               <%# Eval("TotalRead")==null ? "0" : Eval("TotalRead").ToString()%>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <b>No Email here</b>
                    </EmptyDataTemplate>
                    <PagerSettings PageButtonCount="50" Position="Bottom" />
                </asp:GridView>
            </div>
        <br class="clear" />
        <img src="<%= ResolveUrl("~/images/bottom.jpg")%>" align="absbottom" alt="" />
</div>
<div class="content_area1">
        <h2>Gởi mail</h2>
        <div style="padding-left: 30px; margin-bottom: 10px;"><asp:Label ID="lblMessage" runat="server" Visible="false" ForeColor="Blue" Font-Size="15px" Text="Mail được gởi thành công."></asp:Label></div>
        <div style="padding-left: 17px;">
             <div class="rows">
                <span class="leftrow">Gói email:</span>
                <span class="rightrow" style="width: 450px;">
                    <asp:DropDownList ID="ddlEmailTemplate" runat="server" Width="150" AutoPostBack="true" OnSelectedIndexChanged="ddlEmailTemplate_SelectedIndexChanged"></asp:DropDownList>
                    <asp:Label ID="lblAlertRemaind" runat="server" Visible="false" ForeColor="#037bba"></asp:Label>
                </span>
            </div>
            <br class="clear" />
            <div class="rows">
                <span class="leftrow">Đến:</span>
                <span class="rightrow" style="width: 450px;"><asp:TextBox ID="txtSenderId" runat="server" Width="500px"></asp:TextBox></span>
            </div>
            <br class="clear" />
            <div class="rows">
                <span class="leftrow">Tiêu đề:</span>
                <span class="rightrow"><asp:TextBox ID="txtEmailTitle" runat="server" Width="700"></asp:TextBox></span>
            </div>
            <br class="clear" />
            <div class="rows">
                <span class="leftrow">Nội dung:</span>
                <span class="rightrow"><asp:TextBox ID="txtEmailContent" runat="server" TextMode="MultiLine" Width="400" Height="200" ReadOnly="true"></asp:TextBox></span>
            </div>
            <br class="clear" />
            <div class="rows">
                <span class="leftrow">&nbsp;</span>
                <span class="rightrow">
                    <asp:Button ID="btnSendMail" runat="server" Text="Gởi" CssClass="buttonDefault form-submit" OnClick="btnSendMail_Click" OnClientClick="return CheckInput()"/>
                </span>
            </div>
        </div>
        <br class="clear" />
        <img src="<%= ResolveUrl("~/images/bottom.jpg")%>" align="absbottom" alt="" />
</div>
<asp:HiddenField ID="hdMailRemaind" runat="server" Value="0" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>

